{template '_header'}
<div class="page-header">当前位置：
    <span class="text-primary">
        {if !empty($uid)}创业者【{$member['realname']}】的{/if}
        设备管理
    </span>
</div>

<div class="page-content">
<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
    <input type="hidden" name="c" value="site" />
    <input type="hidden" name="a" value="entry" />
    <input type="hidden" name="m" value="mx_shop" />
    <input type="hidden" name="do" value="web" />
    <input type="hidden" name="r" value="sgoods" />
    <input type="hidden" name="uid" value="{$uid}" />

    <div class="page-toolbar">
        <div class="col-sm-2">
            <div class="pull-left">
                {ifp 'sgoods.add'}
                <a class="btn btn-primary btn-sm" href="{php echo webUrl('sgoods/post')}"><i class="fa fa-plus"></i> 添加设备</a>
                {/if}
            </div>
            <div class="input-group-btn">
                <button class="btn btn-default btn-sm"  type="button" data-toggle='refresh'><i class='fa fa-refresh'></i></button>
                {ifp 'sgoods.delete'}
                <button class="btn btn-default btn-sm" type="button" data-toggle='batch-remove' data-confirm="确认要删除?" data-href="{php echo webUrl('sgoods/goodsdel')}"><i class='fa fa-trash'></i> 删除</button>
                {/if}
            </div>
        </div>

        <div class="col-sm-9 pull-right">
            <div class="input-group">
                <div class="input-group-select">
                    <div class="col-xs-3 col-sm-2 col-lg-2">
                        <select name="selprov" class="form-control input-sm select-md" id="selprov" onchange="loadcity();">
                            <option value="0">请选择省</option>
                            {loop $province $row}
                            <option value="{$row['province']}" {if $row['province']==$_GPC['selprov']}selected="selected"{/if}>{$row['province']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="input-group-select">
                    <div class="col-xs-3 col-sm-2 col-lg-2">
                        <select name="selcity" class="form-control input-sm select-md" id="selcity" onchange="loaddist();">
                            <option value="0">请选择市</option>
                            {loop $city $row}
                            <option value="{$row['city']}" {if $row['city']==$_GPC['selcity']}selected="selected"{/if}>{$row['city']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="input-group-select">
                    <div class="col-xs-3 col-sm-2 col-lg-2">
                        <select name="seldist" class="form-control input-sm select-md" id="seldist">
                            <option value="0">请选择区</option>
                            {loop $dist $row}
                            <option value="{$row['dist']}" {if $row['dist']==$_GPC['seldist']}selected="selected"{/if}>{$row['dist']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
                <div class="input-group-select">
                <select name='typeid' class='form-control  input-sm select-md' style="width:110px;"  >
                    <option value='0'>设备种类</option>
                    {loop $goods_type $row}
                    <option value="{$row['id']}" {if $row['id']==$_GPC['typeid']}selected{/if}>{$row['name']}</option>
                    {/loop}
                </select>
                </div>
                <div class="input-group-select">
                <select name='brandsid' class='form-control  input-sm select-md' style="width:110px;"  >
                    <option value='0'>设备品牌</option>
                    {loop $goods_brands $row}
                    <option value="{$row['id']}" {if $row['id']==$_GPC['brandsid']}selected{/if}>{$row['name']}</option>
                    {/loop}
                </select>
                </div>
                <div class="input-group-select">
                    <select name='mendianid' class='form-control  input-sm select-md' style="width:150px;"  >
                        <option value='0'>选择门店</option>
                        {loop $mendian $row}
                        <option value="{$row['id']}" {if $row['id']==$_GPC['mendianid']}selected{/if}>{$row['mendianname']}</option>
                        {/loop}
                    </select>
                </div>
                <div class="input-group-select">
                    <select name='status' class='form-control  input-sm select-md' style="width:100px;"  >
                        <option value="0" {if empty($status)} selected  {/if}>状态</option>
                        <option value="1" {if $status==1} selected  {/if}>显示</option>
                        <option value="2" {if $status==2} selected  {/if} >不显示</option>
                    </select>
                </div>
                <input type="text" class="form-control input-sm"  name="keyword" value="{$_GPC['keyword']}" placeholder="设备关键字"/>
                <span class="input-group-btn">
                    <button class="btn btn-sm btn-primary" type="submit"> 搜索</button>
                </span>
            </div>
        </div>
    </div>
</form>
{if count($list)>0}

<table class="table table-hover table-responsive">
    <thead class="navbar-inner" >
    <tr>
        <th style="width:25px;"><input type='checkbox' /></th>
        <th style='width:50px;'>id</th>
        <th style='width:60px;'>编号</th>
        <th style='width:80px;'>名称</th>
        <th style='width:60px;'>所属种类</th>
        <th style='width:70px;'>所属门店</th>
        <th style='width:80px;'>所属地区</th>
        <th style='width:55px;'>状态</th>
        <th style='width:120px;'>操作</th>
    </tr>
    </thead>
    <tbody>
    {loop $list $row}
    <tr>

        <td>
            <input type='checkbox'   value="{$row['id']}"/>
        </td>

        <td >
            <span>{$row['id']}</span>
        </td>

        <td >
            <span>{$row['docking_number']}</span>
        </td>

        <td >
            <span>
                <span style="cursor: pointer;" data-toggle="popover" data-trigger="hover" data-html="true"
                        data-content="<img src='{$row['qrcode']}' width='130' alt='链接二维码'>" data-placement="auto right">
                    <i class="glyphicon glyphicon-qrcode"></i>
                </span>
                {$row['name']} <br>
                <a class="btn btn-default btn-xs"
                    data-toggle='popover'
                    data-html='true'
                    data-placement='right'
                    data-content="<span style='word-wrap:break-word'>{$row['saleurl']}</span>">
                    购买设备URL
                </a>
            </span>
        </td>

        <td >
            <span>{$row['type_name']}</span>
        </td>

        <td >
            <span>{$row['md_name']}</span>
        </td>

        <td >
            <span>{$row['md_province']}-{$row['md_city']}</span>
        </td>
        <td>
            <span class='label {if $row['status']==1}label-success{else}label-default{/if}'
            {ifp 'sgoods.status'}
            data-toggle='ajaxSwitch'
            data-switch-value='{$row['status']}'
            data-switch-value0='0|不显示|label label-default|{php echo webUrl('sgoods/status',array('status'=>1,'id'=>$row['id']))}'
            data-switch-value1='1|显示|label label-success|{php echo webUrl('sgoods/status',array('status'=>0,'id'=>$row['id']))}'
            {/if}
            >
            {if $row['status']==1}显示{else}不显示{/if}</span>
        </td>
        <td  style="overflow:visible;">
            {ifp 'sgoods.edit'}
            <div class="btn-group btn-group-sm">

                {ifp 'sorder.pay'}
                <a class="btn btn-default dropdown-toggle" target="_blank" href="{php echo webUrl('sorder/all', array('searchfield'=>'goods','keyword'=>$row['name']))}"><i class="fa fa-list"></i>订单</a>
                {/if}
                {ifp 'sgoods.owner'}
                <a class="btn btn-default dropdown-toggle" href="{php echo webUrl('sgoods/owner', array('id'=>$row['id']))}"><i class="fa fa-user"></i>创业者</a>
                {/if}
                <br>
                <a class="btn btn-default dropdown-toggle" href="{php echo webUrl('sgoods/post', array('id'=>$row['id']))}"><i class="fa fa-edit"></i>编辑</a>
                {ifp 'sgoods.delete'}
                <a data-toggle='ajaxRemove' href="{php echo webUrl('sgoods/goodsdel', array('id'=>$row['id']))}" class="btn btn-default btn-sm" data-confirm="确认要删除设备吗?"><i class="fa fa-trash"></i> 删除</a>
                {/if}
            </div>
            {/if}
        </td>
    </tr>
    {/loop}
    </tbody>
</table>
{$pager}

{else}
<div class="panel panel-default">
    <div class="panel-body empty-data">未查询到相关数据</div>
</div>
{/if}
</div>
<script language="javascript">

    function loadcity() {

        $("#selcity").html( '<option value="0">请选择市</option>');
        $("#seldist").html( '<option value="0">请选择区</option>');
        var str = $("#selprov").val();
        if(str!=0) {
            $.post("{php echo webUrl('mendian/mdajax',array('foo'=>'city'));}", {str: str}, function (data) {
                if (data.status == 1) {
                    var json = data.data;
                    var _html = '<option value="0">请选择市</option>';
                    for (var o in json) {
                        if (json[o].city != '') {
                            _html += '<option value="' + json[o].city + '" >' + json[o].city + '</option>';
                        }
                    }
                    $("#selcity").html(_html);
                }

            }, 'json')
        }
    }

    function loaddist(){


        $("#seldist").html( '<option value="0">请选择区</option>');
        var selcity = '#selcity';
        var str=$(selcity).val();
        if(str != 0) {

            $.post("{php echo webUrl('mendian/mdajax',array('foo'=>'dist'));}", {str: str}, function (data) {
                if (data.status == 1) {
                    var json = data.data;
                    var _html = '<option value="0">请选择区</option>';
                    for (var o in json) {
                        if(json[o].dist != ''){
                            _html += '<option value="' + json[o].dist + '" >' + json[o].dist + '</option>';
                        }
                    }
                    $('#seldist').html(_html);
                }

            }, 'json')
        }
    }

</script>

{template '_footer'}